package com.fourGirlsAndADude.mobileDRT;

import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class AdminMenuActivity extends Activity {

	private Button geoloc;
	private String token;
	private String authType;
	private String username;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_admin_menu);
		// Receiving token and authorization type
		token = this.getIntent().getStringExtra("SESSION_TOKEN").toString();
		Log.v("AdminMenuActivity", "Token: " + token);
		authType = this.getIntent().getStringExtra("AUTHORIZATION_TYPE")
				.toString();
		Log.v("AdminMenuActivity", "Authorization type: " + authType);
		username = this.getIntent().getStringExtra("USER_NAME");
		Log.v("AdminMenuActivity", "Username: " + username);
		
		//Defining UI elements
		Log.v("AdminMenuActivity", "Defining geoloc button");
		geoloc = (Button) findViewById(R.id.geolocButton);
		Log.v("AdminMenuActivity", "Setting on click listener");
		geoloc.setOnClickListener(new buttonListener());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.admin_menu, menu);
		return true;
	}

	private class buttonListener implements Button.OnClickListener {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Log.v("AdminMenuActivity", "Creating intent");
			Intent intent = new Intent(getBaseContext(),
					SearchableActivity.class);
			Log.v("AdminMenuActivity", "Adding extras");
			intent.putExtra("USER_NAME", username);
			intent.putExtra("STRING_TOKEN", token);
			intent.putExtra("AUTHORIZATION_TYPE", authType);
			Log.v("AdminMenuActivity", "starting intent");
			startActivity(intent);
		}
	}

	private class listenerButton implements Button.OnClickListener {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			Log.v("AdminMenuActivity", "Creating intent");
			Intent intent = new Intent(getBaseContext(),
					SearchableActivity.class);
			Log.v("AdminMenuActivity", "Adding extras");
			intent.putExtra("USER_NAME", username);
			intent.putExtra("STRING_TOKEN", token);
			intent.putExtra("AUTHORIZATION_TYPE", authType);
			Log.v("AdminMenuActivity", "starting intent");
			startActivity(intent);
		}

	}

}
